package com.itheima.media.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.common.pojo.PageRequestDto;
import com.itheima.media.dto.WmNewsVo;
import com.itheima.media.pojo.WmNews;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 自媒体图文内容信息表 Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2021-08-20
 */
public interface WmNewsMapper extends BaseMapper<WmNews> {

    /**
     * 根据ID删除
     * @param id
     * @return
     */
    @Delete("DELETE FROM wm_news WHERE id=#{id} AND status IN(0,1,2) AND enable=0")
    int deleteWmNewsById(@Param("id") Serializable id);

    /**
     * 上架、下架
     * @param id
     * @param enable
     * @return
     */
    @Update("update wm_news set enable=#{enable} where id=#{id} and status=9")
    int updateUpDown(@Param("id")Integer id, @Param("enable")Integer enable);

    Long findWmNewsCount(WmNews body);

    List<WmNewsVo> findWmNewsPages(PageRequestDto<WmNews> dto);


}
